<template>
  <el-dropdown @command="handleCommand">
    <span class="el-dropdown-link">
      superadmin
      <el-icon class="el-icon--right">
        <arrow-down />
      </el-icon>
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item command="layout">退出登录</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup lang="ts">
import { ElMessage } from 'element-plus';
import {useRouter} from 'vue-router';
// 获取仓库
import loginStore from "@/store/modules/login";
// 仓库实例化
const loginSt = loginStore();

const router = useRouter()
// 下拉触发
const handleCommand = (command: string | number | object) => {
//   console.log(212, command);
  switch (command) {
    case 'layout':
        handleLayout()
        break;
  
    default:
        break;
  }
  
};
/**
 * 退出登录
 */
const handleLayout=()=>{
  loginSt.loginOut()
    router.replace('/')
    ElMessage.info("已退出登录");
}
</script>

<style scoped lang="scss"></style>
